var localStorage = window.localStorage;
/**
 * 用户管理接口
 *
 */
var ITEM_LOCAL = {
  CURRENT_USER_KEY: 'idi_current_user'
};

/**
 * 获取当前登录用户
 * @return {Object} current user.
 */
function getUser() {
  var v = localStorage.getItem(ITEM_LOCAL.CURRENT_USER_KEY);
  if (v) {
    try {
      v = JSON.parse(v);
    } catch (err) {
      v = null;
    }
  }
  return v;
}
exports.getUser = getUser;
/**
 * 保存登录用户user信息
 *
 */
function saveUser(user) {
  localStorage.setItem(ITEM_LOCAL.CURRENT_USER_KEY, JSON.stringify(user));
}
exports.saveUser = saveUser;
/**
 * 删除登录用户user信息
 *
 */
function DelUser(user) {
  localStorage.removeItem(ITEM_LOCAL.CURRENT_USER_KEY);
}
exports.DelUser = DelUser;
